<?php
#### Roshan's Ajax dropdown code with php
#### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
#### if you have any problem contact me at http://roshanbh.com.np
#### fell free to visit my blog http://php-ajax-guru.blogspot.com
?>

<?php $region=$_GET['region'];
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('project192');
$query="select distinct province from philippines where region=\"$region\"";
$result=mysql_query($query);
?>

<select name="province" id="province" onChange="getCity('http://localhost/pollwatcher/getcity.php?province='+this.value);">
<option></option>
<?php while($row=mysql_fetch_array($result)) { ?>
<?php if($_GET['province'] == $row['province'])
	{
		?><option value="<?php echo $row['province']?>" selected="selected"><?php echo $row['province']?></option><?php
	}
	
	else
	{
		?><option value="<?php echo $row['province']?>"><?php echo $row['province']?></option><?php
	}?>


<?php } ?>
</select>
